<?php

namespace app\models;

use Yii;

/**
 * This is the model class for table "price".
 *
 * @property integer $id
 * @property string $name
 * @property string $market
 * @property double $price_kg
 * @property double $price_jin
 * @property string $date
 */
class Price extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'price';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['name', 'market', 'price_kg', 'price_jin', 'date'], 'required'],
            [['price_kg', 'price_jin'], 'number'],
            [['name', 'date'], 'string', 'max' => 11],
            [['market'], 'string', 'max' => 20],
            [['date', 'market', 'name'], 'unique', 'targetAttribute' => ['date', 'market', 'name'], 'message' => 'The combination of 品种名称, 市场名称 and 报送日期 has already been taken.'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'name' => '品种名称',
            'market' => '市场名称',
            'price_kg' => '每公斤价格',
            'price_jin' => '每斤价格',
            'date' => '报送日期',
        ];
    }
}
